//
//  ContactWayViewController.m
//  ShangPiBao
//
//  Created by chirui on 2017/10/25.
//  Copyright © 2017年 Shui. All rights reserved.
//

#import "ContactWayViewController.h"

@interface ContactWayViewController ()

@property (weak, nonatomic) IBOutlet UITextField *addressText;
@property (weak, nonatomic) IBOutlet UITextField *phoneNumber;
@property (weak, nonatomic) IBOutlet UITextField *phoneText;
@property (weak, nonatomic) IBOutlet UITextField *userName;
@property (weak, nonatomic) IBOutlet UITextField *netAddress;
@property (weak, nonatomic) IBOutlet UIButton *keepBtn;

@end

@implementation ContactWayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    TitleView(@"联系方式");
    
    _keepBtn.layer.cornerRadius = 45/2.f;
    _keepBtn.layer.masksToBounds = YES;
    NSArray * array;
    if (self.dataStr.length>0) {
        
        array = [self.dataStr componentsSeparatedByString:@"|"];
        _addressText.text= array[0];
        _phoneNumber.text = array[1];
        _phoneText.text = array[2];
        _userName.text = array[3];
        _netAddress.text = array[4];
    }
    
    
//    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithIcon:@"icon_nav_return" target:self action:@selector(back)];
}
-(void)back{
    
    [self.navigationController popViewControllerAnimated:YES];
}


- (IBAction)keepBtnClick:(id)sender {
    
    NSString * endStr;
    if (_addressText.text.length==0||_addressText.text==nil) {
        
        SHuiMBhudTextTimeStr(@"请输入地址");
        return;
    }else {
        
        endStr = _addressText.text;
    }
    if (_phoneNumber.text.length==0||_phoneNumber.text==nil) {
        SHuiMBhudTextTimeStr(@"请输入电话/传真");
        return;
    }else {
        endStr = [NSString stringWithFormat:@"%@|%@",_addressText.text,_phoneText.text];
    }
    if (_phoneText.text.length==0||_phoneText.text==nil) {
        SHuiMBhudTextTimeStr(@"请输入手机号");
        return;
    }else {
        endStr = [NSString stringWithFormat:@"%@|%@|%@",_addressText.text,_phoneText.text,_phoneText.text];
    }
    
    if (_userName.text.length==0||_userName.text==nil) {
        SHuiMBhudTextTimeStr(@"请输入联系人");
        return;
    }else {
        endStr = [NSString stringWithFormat:@"%@|%@|%@|%@",_addressText.text,_phoneText.text,_phoneText.text,_userName.text];
        
    }
    if (_netAddress.text.length==0||_netAddress.text==nil) {
        SHuiMBhudTextTimeStr(@"请输入网址");
        return;
    }else {
        endStr = [NSString stringWithFormat:@"%@|%@|%@|%@|%@",_addressText.text,_phoneText.text,_phoneText.text,_userName.text,_netAddress.text];
    }
    self.infoBlock(endStr);
    [self.navigationController popViewControllerAnimated:YES];
}


@end
